package com.spark.gaea.utils;

import com.google.common.collect.Maps;

import java.util.Map;

public final class ExtUtil {
	public static Map<String, Object> success() {
		return o2e(true, null);
	}

	public static Map<String, Object> success(final Object o) {
		return o2e(true, o);
	}

	public static Map<String, Object> failure() {
		return o2e(false, null);
	}

	public static Map<String, Object> failure(final Object o) {
		return o2e(false, o);
	}

	private static Map<String, Object> o2e(final boolean success, final Object o) {
		final Map<String, Object> result = Maps.newHashMap();
		result.put("success", success);
		if (o != null) {
			result.put("data", o);
		}
		return result;
	}
}
